//
//  ZYXVideoViewController.m
//  RuiBeiKang
//
//  Created by iOS开发1 on 2019/1/2.
//  Copyright © 2019年 JW. All rights reserved.
//

#import "ZYXVideoViewController.h"

#import "ZYXComeHeaderView.h"
#import "ZYXLoadingVC.h"
#import "ZYXDownVC.h"
@interface ZYXVideoViewController ()<ZYXComeHeaderViewDelegate>
@property (strong,nonatomic) NSString *typeStr;
@property (strong,nonatomic) ZYXComeHeaderView *headerView;

@property (strong,nonatomic) ZYXDownVC *oneVC;
@property (strong,nonatomic) ZYXLoadingVC *twoVC;
@end

@implementation ZYXVideoViewController
- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"qwertyuiop" object:nil];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setTitle:@"视频"];
    
}
-(void)setupViews{
    self.headerView = [[ZYXComeHeaderView alloc]initWithFram:CGRectMake(0, 0, SCREEN_WIDTH, HEIGHT(48)) TitleOne:@"已下载" andTitleTwo:@"正在下载"];
    self.headerView.delegate =self;
    [self.view addSubview:self.headerView];
    [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.left.offset(0);
        make.right.offset(0);
        make.height.offset(HEIGHT(48));
    }];
    
    self.scroView.frame = CGRectMake(0, HEIGHT(48), SCREEN_WIDTH, SCREEN_HEIGHT-HEIGHT(48)-NavigationBar_Height);
    self.scroView.scrollEnabled = NO;
    self.scroView.contentSize = CGSizeMake(SCREEN_WIDTH*2, 0);
    [self.view addSubview:self.scroView];
    [self addChildVC];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clickCheakDown) name:@"qwertyuiop" object:nil];
    
    
}
-(void)clickCheakDown{
    NSLog(@"++++");
    
//    [self.headerView ClickTwoBtn:self.headerView.twoBtn];
    
}
#pragma mark 添加子视图
-(void)addChildVC{
    self.oneVC = [[ZYXDownVC alloc] init];
    self.oneVC.view.frame = CGRectMake(0, 0, SCREEN_WIDTH, self.scroView.height);
    [self addChildViewController:self.oneVC];
    [self.scroView addSubview:self.oneVC.view];
    
    self.twoVC = [[ZYXLoadingVC alloc] init];
    self.twoVC.view.frame = CGRectMake(SCREEN_WIDTH, 0, SCREEN_WIDTH, self.scroView.height);
    [self addChildViewController:self.twoVC ];
    [self.scroView addSubview:self.twoVC.view];
    
}
#pragma mark ZYXComeHeaderViewDelegate
-(void)clickBtnWith:(NSString *)typeStr{
    self.typeStr = typeStr;
    if ([typeStr isEqualToString:@"one"]) {
     
        self.scroView.contentOffset = CGPointMake(0, 0);
           [self.oneVC getCacheVideoList];
    }else{

        self.scroView.contentOffset = CGPointMake(SCREEN_WIDTH, 0);
        [self.twoVC getCacheVideoList];
    }
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    if ([UID integerValue] >0) {
        
    }else{
      
        
//        BaseNavigationVC *nav = [[BaseNavigationVC alloc] initWithRootViewController:ctrl];
//        APPDelegate.window.rootViewController = nav;
//        [APPDelegate.window makeKeyAndVisible];
        
        [ZYXLoginViewController setupLogin];
        
    }
    
}


@end
